<template>
  <div class="content">
    <div v-if="successFailure" v-loading="loading" class="content_box">
      <img src="@assets/icon/beforeSettle/shenhetongguo.png" alt="" />
      <p>已成功跳转至销货报表页</p>
    </div>
    <div v-else class="content_box">
      <img src="@assets/icon/beforeSettle/shenheshibai.png" alt="" />
      <p>暂未分配经销商，请去销售管理分配经销商</p>
    </div>
    <a ref="hrefLink" :href="hrefLink" target="_blank"></a>
  </div>
</template>
<script>
export default {
  data() {
    return {
      loading: false,
      accountNumber: '',
      auth: '',
      successFailure: true,
      hrefLink: ''
    };
  },
  mounted() {
    this.getOrderNotPaid();
  },
  methods: {
    getOrderNotPaid() {
      this.loading = true;
      this.$axios
        .$post('m-mall-center/api/v1/mdm/getAccountNumberByCompanyId')
        .then(res => {
          if (res.code === '0') {
            const { payload } = res;
            this.accountNumber = payload.accountNumber;
            this.auth = payload.auth;
            this.successFailure = !!payload.auth;
          }
          if (this.successFailure) {
            this.hrefLink = `https://bi.gkht.com/WebReport/ReportServer?op=fr_bi&cmd=bi_init&id=520&openFromShare=true&systemManager=true&createBy=-999&auth=${this.auth}&account_number=${this.accountNumber}`;
            this.$nextTick(() => {
              this.$refs.hrefLink.click();
            });
          }
        })
        .finally(() => {
          this.loading = false;
        });
    }
  }
};
</script>
<style lang="less">
.content {
  height: 100%;
  .content_box {
    margin-top: 150px;
    img {
      display: block;
      margin: 0 auto;
    }
    p {
      text-align: center;
      font-size: 28px;
      color: #333;
      font-weight: 550;
    }
  }
}
</style>
